home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1997 August
/
Walnut Creek CDROM.7z
/
LISTINGS
/
V_13_04
/
ALLISON.ZIP
/
SWAP.CPP
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1995-02-07
|
352 b
|
27 lines
LISTING 7 - A swap function that illustrates call-by-reference
// swap.cpp
#include <stdio.h>
void swap(int &, int &);
main()
{
int i = 1, j = 2;
swap(i,j);
printf("i == %d, j == %d\n",i,j);
return 0;
}
void swap(int &x, int &y)
{
int temp = x;
x = y;
y = temp;
}
// Output:
i == 2, j == 1